Crate base58_monero[][src]

Monero Base58

Monero base58 is not like Bitcoin base58, bytes are converted in 8-byte blocks. The last block can have less than 8 bytes, but at least 1 byte. Eight bytes converts to 11 or less Base58 characters; if a particular block converts to <11 characters, the conversion pads it with “1“s (1 is 0 in Base58). Likewise, the final block can convert to 11 or less Base58 digits.

Due to the conditional padding, the 69-byte string, like Monero addresses, will always convert to 95 Base58 characters (8 * 11 + 7); where 7 is length of the last block of 5 bytes.

The alphabet is composed of 58 characters visually not similar to avoid confusion, e.g. both 1 and l are not part of the alphabet together, only 1 is present. The full alphabet is composed of: 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz

Examples

Encoding and decoding an array of bytes with Monero base58 format:

use base58_monero::{encode, decode, Error};

let input = b"Hello World";
let encoded_input = encode(input)?;

let decoded_input = decode(&encoded_input)?;

assert_eq!(&input[..], &decoded_input[..]);

With feature = check Monero base58 also comes with a checksum mode. The checksum is composed with the first 4 bytes of a Keccak256 result of the string. Encoding and decoding with a checksum:

use base58_monero::{encode_check, decode_check, Error};

let input = b"Hello World";
let encoded_input = encode_check(input)?;

let decoded_input = decode_check(&encoded_input)?;

assert_eq!(&input[..], &decoded_input[..]);

Re-exports

pub use base58::decode;
pub use base58::decode_check;
pub use base58::decode_stream;
pub use base58::decode_stream_check;
pub use base58::encode;
pub use base58::encode_check;
pub use base58::encode_stream;
pub use base58::encode_stream_check;
pub use base58::Error;

Modules

base58

Base58 encoder and decoder